<template>
	<view class="waterfall-item-container">
		<view class="waterfall-item" @tap="onTap">
			<view class="hd">
				<image class="img" :src="params.litpic" mode="widthFix" @load="emitHeight" @error="emitHeight"></image>
				<view class="label-bar">
					<view class="label">{{params.model_name}}</view>
					<image v-if="params.has_video" :src="'https://static.member.stourweb.cn/uniapp/static/images/' + 'play.png'" mode="scaleToFill"></image>
				</view>
			</view>
			<view class="content">
				<view class="title">{{params.title}}</view>
				
				<template v-if="params.typeid != 4 && params.typeid != 101 && params.typeid != 115">
					<view class="price" v-if="params.price > 0">¥<text class="num">{{params.price}}</text>起</view>
					<view class="price" v-else>电询</view>
				</template>
				
				<view class="source" v-if="(params.typeid == 4 || params.typeid == 101 || params.typeid == 115) && params.author">
					{{params.author}}</view>
				
				<!-- <view class="money">{{params.price}}元</view>
				<view style="margin: 0 0 8rpx 0;">
					<text class="label">{{params.label}}</text>
				</view>
				<view class="shop-name">{{params.shop}}</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"helangWaterfallItem",
		options:{
			virtualHost: true
		},
		props:{
			params:{
				type: Object,
				default(){
					return {}
				}
			},
			tag:{
				type:String | Number,
				default:''
			},
			index:{
				type:Number,
				default:-1
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e){
				setTimeout(() => {
					const query = uni.createSelectorQuery().in(this);
					query.select('.waterfall-item-container').boundingClientRect(data => {
						let height = Math.floor(data.height);
						this.$emit("height",height,this.$props.tag);
					}).exec();
				}, 0)
			},
			onTap(){
				this.$emit("click",this.$props.index,this.$props.tag);
			}
		}
	}
</script>

<style lang="scss" scoped>
.waterfall-item{
	font-size: 28rpx;
	color: #666;
	
	.hd{
		position: relative;
		.img{
			display: block;
			width: 100%;
			// 默认设置一个图片的大约值
			height: 350rpx;
			border-radius: 14px;
		}
		.label-bar{
			display: flex;
			align-items: center;
			justify-content: space-between;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			z-index: 10;
			padding: 20rpx;
			.label{
				color: #fff;
				height: 32rpx;
				line-height: 32rpx;
				padding: 4rpx 24rpx;
				font-size: 20rpx;
				border-radius: 80rpx;
				background: rgba(0,0,0,.5);
			}
			image{
				width: 32rpx;
				height: 32rpx;
			}
		}
	}
	
	.content{
		margin-top: 16rpx;
		
		.title{
			word-break: break-all;
			max-height: 72rpx;
			line-height: 36rpx;
			display: -webkit-box; 
			-webkit-box-orient: vertical;    //方向
			-webkit-line-clamp: 2;         //设置在第几行添加省略号
			overflow: hidden;
			text-overflow: ellipsis;
			word-break: break-all;
		}
		
		.price {
			color: #FF6913;
			margin-top: 12rpx;
			font-size: 24rpx;
			
			.num {
				font-size: 36rpx;
				font-weight: bold;
				font-family: Arial, Helvetica, sans-serif;
			}
		}
		
		.source {
			color: #999;
			margin-top: 12rpx;
			font-size: 24rpx;
		}
		
		.label{
			background-color: #fa3534;
			color: #fff;
			font-size: 20rpx;
			padding: 4rpx 16rpx;
			border-radius: 20rpx;
		}
		
		.shop-name{
			font-size: 20rpx;
			color: #999;
		}
	}
}
</style>
